package cn.wolfcode.luowowo.advice;


import cn.wolfcode.luowowo.exception.LogicException;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.rmi.runtime.Log;

@ControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public Object logic( Exception e){
        e.printStackTrace();
        return new JsonResult(JsonResult.CODE_ERROR_PARAM,e.getMessage(),null);
    }
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Object runTime( Exception e){
        e.printStackTrace();
        return new JsonResult(JsonResult.CODE_ERROR_PARAM,"系统发生异常,请联系管理员",null);
    }
}
